thermostat6 2.2.1
Loading...
Searching...
No Matches
thermostat6.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
27
28#ifndef THERMOSTAT6_H
29#define THERMOSTAT6_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_analog_in.h"
52#include "drv_i2c_master.h"
53
59
64
69
74#define THERMOSTAT6_ADC_RESOLUTION 0x0FFF
75#define THERMOSTAT6_VREF_3V3 3.3
76#define THERMOSTAT6_VREF_5V 5.0
77#define THERMOSTAT6_ADC_NUM_SAMPLES_50 50
78
84#define THERMOSTAT6_SET_DEV_ADDR 0x4D
85 // thermostat6_set
87
92
97
102#define THERMOSTAT6_MAP_MIKROBUS( cfg, mikrobus ) \
103 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
104 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
105 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
106 cfg.relay = MIKROBUS( mikrobus, MIKROBUS_PWM );
107 // thermostat6_map // thermostat6
110
115typedef struct
116{
117 digital_in_t relay;
118
119 analog_in_t adc;
120 i2c_master_t i2c;
121
123 float vref;
124
126
131typedef struct
132{
133 pin_name_t an;
134 pin_name_t scl;
135 pin_name_t sda;
136 pin_name_t relay;
137
138 analog_in_resolution_t resolution;
139 float vref;
140
141 uint32_t i2c_speed;
142 uint8_t i2c_address;
143
145
156
162
173
188
200err_t thermostat6_get_adc_v ( thermostat6_t *ctx, float *voltage );
201
214err_t thermostat6_get_adc_v_avg ( thermostat6_t *ctx, float *voltage, uint16_t num_samples );
215
227err_t thermostat6_get_an_pin_v ( thermostat6_t *ctx, float *voltage );
228
241err_t thermostat6_get_an_pin_v_avg ( thermostat6_t *ctx, float *voltage, uint16_t num_samples );
242
255err_t thermostat6_set_vref ( thermostat6_t *ctx, float vref );
256
266
275float thermostat6_get_temperature ( float voltage );
276
277#ifdef __cplusplus
278}
279#endif
280#endif // THERMOSTAT6_H
281 // thermostat6
283
284// ------------------------------------------------------------------------ END
err_t thermostat6_get_adc_v_avg(thermostat6_t *ctx, float *voltage, uint16_t num_samples)
Thermostat 6 get adc voltage average function.
void thermostat6_cfg_setup(thermostat6_cfg_t *cfg)
Thermostat 6 configuration object setup function.
uint8_t thermostat6_get_relay_pin(thermostat6_t *ctx)
Thermostat 6 get relay pin function.
err_t thermostat6_get_an_pin_v(thermostat6_t *ctx, float *voltage)
Thermostat 6 get AN pin voltage function.
err_t thermostat6_get_an_pin_v_avg(thermostat6_t *ctx, float *voltage, uint16_t num_samples)
Thermostat 6 get AN pin voltage function.
float thermostat6_get_temperature(float voltage)
Thermostat 6 get temperature function.
err_t thermostat6_init(thermostat6_t *ctx, thermostat6_cfg_t *cfg)
Thermostat 6 initialization function.
err_t thermostat6_set_vref(thermostat6_t *ctx, float vref)
Thermostat 6 set vref function.
err_t thermostat6_get_adc_v(thermostat6_t *ctx, float *voltage)
Thermostat 6 get adc voltage function.
Thermostat 6 Click configuration object.
Definition thermostat6.h:132
analog_in_resolution_t resolution
Definition thermostat6.h:138
float vref
Definition thermostat6.h:139
uint32_t i2c_speed
Definition thermostat6.h:141
pin_name_t scl
Definition thermostat6.h:134
pin_name_t sda
Definition thermostat6.h:135
pin_name_t relay
Definition thermostat6.h:136
pin_name_t an
Definition thermostat6.h:133
uint8_t i2c_address
Definition thermostat6.h:142
Thermostat 6 Click context object.
Definition thermostat6.h:116
digital_in_t relay
Definition thermostat6.h:117
float vref
Definition thermostat6.h:123
i2c_master_t i2c
Definition thermostat6.h:120
uint8_t slave_address
Definition thermostat6.h:122
analog_in_t adc
Definition thermostat6.h:119
thermostat6_return_value_t
Thermostat 6 Click return value data.
Definition thermostat6.h:151
@ THERMOSTAT6_ERROR
Definition thermostat6.h:153
@ THERMOSTAT6_OK
Definition thermostat6.h:152